home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / objeas3a / workshop / workshop.cpp < prev    next >
C/C++ Source or Header  |  1994-05-18  |  30KB  |  1,181 lines

  1. #include "d:\gui\gui.h"
  2. #include "workshop.h"
  3. #include <conio.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <alloc.h>
  7.  
  8. //*********************************************************************
  9. //        PROTOTYPES
  10. //*********************************************************************
  11.  
  12. void initialize();
  13. void SetupToolBox();
  14. void design();
  15. void deinitialize();
  16. void showmem();
  17. void redraw_screen();
  18. int check_toolbox();
  19. int check_panels();
  20. int panel_hit();
  21. int panel_sizerhit();
  22. int check_bevels();
  23. int bevel_hit();
  24. int bevel_sizerhit();
  25. int check_checkboxes();
  26. int checkbox_hit();
  27. int check_radios();
  28. int radio_hit();
  29. int check_icons();
  30. int icon_hit();
  31. int check_strings();
  32. int string_hit();
  33. int check_buttons();
  34. int button_hit();
  35. int check_lines();
  36. int line_hit();
  37. int check_texts();
  38. int text_hit();
  39.  
  40. //ACTIONS.CPP
  41. extern void set_screen_color();
  42. extern void place_panel();
  43. extern void place_bevel();
  44. extern void place_checkbox();
  45. extern void place_radio();
  46. extern void place_icon();
  47. extern void place_string();
  48. extern void place_button();
  49. extern void place_line();
  50. extern void place_text();
  51.  
  52. //MODIFY.CPP
  53. extern int modify_panel(panelrec *);
  54. extern modify_bevel(bevelrec *);
  55. extern modify_checkbox(checkboxrec *);
  56. extern modify_radio(radiorec *);
  57. extern modify_icon(iconrec *);
  58. extern modify_string(stringrec *);
  59. extern modify_button(buttonrec *);
  60. extern modify_text(textrec *);
  61.  
  62. //FILEIO.CPP
  63. extern save_all_info();
  64. extern read_new_info();
  65. extern clear_all_info(int);
  66.  
  67. //*********************************************************************
  68. //        GLOBAL VARIABLES
  69. //*********************************************************************
  70.  
  71. panelrec *panelroot=(panelrec *)NULL;
  72. panelrec *currentpanel=(panelrec *)NULL;
  73. int numpanels=0;
  74.  
  75. bevelrec *bevelroot=(bevelrec *)NULL;
  76. bevelrec *currentbevel=(bevelrec *)NULL;
  77. int numbevels=0;
  78.  
  79. checkboxrec *checkboxroot=(checkboxrec *)NULL;
  80. checkboxrec *currentcheckbox=(checkboxrec *)NULL;
  81. int numcheckboxes=0;
  82.  
  83. radiorec *radioroot=NULL;
  84. radiorec *currentradio=NULL;
  85. int numradios=0;
  86.  
  87. iconrec *iconroot=NULL;
  88. iconrec *currenticon=NULL;
  89. int numicons=0;
  90.  
  91. stringrec *stringroot=NULL;
  92. stringrec *currentstring=NULL;
  93. int numstrings=0;
  94.  
  95. buttonrec *buttonroot=NULL;
  96. buttonrec *currentbutton=NULL;
  97. int numbuttons=0;
  98.  
  99. Line line_info[100];
  100. int numlines=0;
  101.  
  102. textrec *textroot=NULL;
  103. textrec *currenttext=NULL;
  104. int numtexts=0;
  105.  
  106. int done=0;
  107.  
  108. Screen screen;
  109. extern Mcursor the_mouse;
  110. Buttonbox toolbox;
  111. int screencolor=0;
  112. int mem_indicator=1;
  113. int pos_indicator=1;
  114. int toolbox_indicator=1;
  115. int mem_turned_on=1;
  116. int pos_turned_on=1;
  117. int toolbox_turned_on=1;
  118. int ready_to_place=0;
  119. int mouse_forced=0;
  120.  
  121. //*********************************************************************
  122. //        MAIN
  123. //*********************************************************************
  124.  
  125. void main()
  126. {
  127.     clrscr();
  128.     initialize();
  129.     SetupToolBox();
  130.     the_mouse.arm();
  131.     design();
  132.     deinitialize();
  133. }
  134.  
  135. //*********************************************************************
  136. //        INITIALIZE
  137. //*********************************************************************
  138.  
  139. void initialize()
  140. {
  141.     screen.VGA_480_16();
  142.     if(!the_mouse.init()) {
  143.         closegraph();
  144.         puts("This program requires a mouse!");
  145.         exit(0);
  146.         }
  147. }
  148.  
  149. //*********************************************************************
  150. //        DEINITIALIZE
  151. //*********************************************************************
  152.  
  153. void deinitialize()
  154. {
  155.     closegraph();
  156. }
  157.  
  158. //*********************************************************************
  159. //        SETUPTOOLBOX
  160. //*********************************************************************
  161.  
  162. void SetupToolBox()
  163. {
  164.     toolbox.init(10,10,14);
  165.     toolbox.setbutton(0,"lines");
  166.     toolbox.setbutton(1,"button");
  167.     toolbox.setbutton(2,"panel");
  168.     toolbox.setbutton(3,"bevel");
  169.     toolbox.setbutton(4,"icon");
  170.     toolbox.setbutton(5,"gstring");
  171.     toolbox.setbutton(6,"radio");
  172.     toolbox.setbutton(7,"check");
  173.     toolbox.setbutton(8,"fromdisk");
  174.     toolbox.setbutton(9,"todisk");
  175.     toolbox.setbutton(10,"screen");
  176.     toolbox.setbutton(11,"text");
  177.     toolbox.setbutton(12,"poof");
  178.     toolbox.setbutton(13,"exit");
  179.  
  180.     toolbox.show();
  181. }
  182.  
  183. //*********************************************************************
  184. //        DESIGN
  185. //*********************************************************************
  186.  
  187. void design()
  188. {
  189.     int mx,my,deltax,deltay;
  190.     char ch;
  191.     int i;
  192.  
  193.     while(!done) {//1
  194.         showmem();
  195.  
  196. //*****   CHECK FOR MOUSE POSITION AND CURRENT SHAPE   *****
  197.         if((panel_sizerhit() || bevel_sizerhit() || line_hit()) &&
  198.            (!toolbox.moverhit() && !toolbox.hit())) {
  199.             the_mouse.changeto(POINT);
  200.             mouse_forced=1;
  201.             }
  202.         else
  203.         if((panel_hit() || bevel_hit() || checkbox_hit() ||
  204.             radio_hit() || icon_hit() || string_hit() || button_hit()
  205.                         || text_hit())
  206.             && (!toolbox.moverhit() && !toolbox.hit())) {
  207.             the_mouse.changeto(HAND);
  208.             mouse_forced=1;
  209.             }
  210.         else
  211.             mouse_forced=0;
  212.  
  213.         if(!mouse_forced) {
  214.             if(toolbox.moverhit())
  215.                 the_mouse.changeto(FINGER);
  216.             else
  217.                 the_mouse.changeto(ARROW);
  218.             }
  219.  
  220.  
  221. //*****   CHECK FOR RIGHT MOUSE BUTTON  (REDRAW SCREEN)
  222.         if(the_mouse.RBP()) {
  223.             redraw_screen();
  224.             while(the_mouse.RBP());
  225.             continue;
  226.             }
  227.  
  228. //*****   CHECK FOR ALT KEY COMBINATIONS   *****
  229.  
  230.         if(kbhit()) {//2
  231.             if(altkey()) {//3
  232.                 ch=getch();
  233.                 ch=getch();
  234.                 switch(ch) {//4
  235.                     case ALTM:    if(mem_indicator)mem_indicator=0;
  236.                                 else {//5
  237.                                     mem_indicator=1;
  238.                                     mem_turned_on=1;
  239.                                     }//5
  240.                                 if(mem_indicator==0) {//5
  241.                                     setfillstyle(SOLID_FILL,screencolor);
  242.                                     bar(0,getmaxy()-10,100,getmaxy());
  243.                                     }//5
  244.                                 continue;
  245.                     case ALTT:    if(toolbox_indicator)toolbox_indicator=0;
  246.                                 else {
  247.                                     toolbox_indicator=1;
  248.                                     toolbox_turned_on=0;
  249.                                     }
  250.                                 if(toolbox_indicator==0)
  251.                                     toolbox.hide();
  252.                                 else
  253.                                     toolbox.show();
  254.                                 continue;
  255.                     }//4
  256.                 }//3
  257.             flushkeys();
  258.             }//2        END ALT KEY COMBINATION CHECK
  259.  
  260. //*****   CHECK THE GRAPHIC OBJECTS   *****
  261.  
  262.         check_toolbox();
  263.         check_texts();
  264.         check_lines();
  265.         check_buttons();
  266.         check_strings();
  267.         check_icons();
  268.         check_radios();
  269.         check_checkboxes();
  270.         check_panels();
  271.         check_bevels();
  272.  
  273.     }//1        END WHILE NOT DONE
  274. }
  275.  
  276. //*********************************************************************
  277. //        SHOWMEM
  278. //*********************************************************************
  279.  
  280. void showmem()
  281. {
  282.     static long memwas;
  283.     long mem;
  284.  
  285.     if(!mem_indicator)
  286.         return;
  287.     mem=farcoreleft();
  288.     if(mem!=memwas || mem_turned_on) {
  289.         setfillstyle(SOLID_FILL,0);
  290.         bar(0,getmaxy()-10,70,getmaxy());
  291.         setcolor(15);
  292.         settextjustify(LEFT_TEXT,TOP_TEXT);
  293.         settextstyle(0,0,1);
  294.         gprintxy(5,getmaxy()-8,"%ld",mem);
  295.         memwas=mem;
  296.         mem_turned_on=0;
  297.         }
  298. }
  299.  
  300. //*********************************************************************
  301. //        REDRAW_SCREEN
  302. //*********************************************************************
  303.  
  304. void redraw_screen()
  305. {
  306.     int i;
  307.  
  308.     if(toolbox.isshown())
  309.         toolbox.hide();
  310.  
  311.     screen.fill(screencolor);
  312.  
  313.     currentbevel=bevelroot;
  314.     while(currentbevel!=(bevelrec *)NULL) {
  315.         if(currentbevel->bevel!=(Bevel *)NULL)
  316.             currentbevel->bevel->show();
  317.         currentbevel=currentbevel->next;
  318.         }
  319.  
  320.     currentpanel=panelroot;
  321.     while(currentpanel!=(panelrec *)NULL) {
  322.         if(currentpanel->panel!=(Panel *)NULL)
  323.             currentpanel->panel->show();
  324.         currentpanel=currentpanel->next;
  325.         }
  326.  
  327.     currentcheckbox=checkboxroot;
  328.     while(currentcheckbox!=(checkboxrec *)NULL) {
  329.         if(currentcheckbox->checkbox!=(Gcheckbox *)NULL)
  330.             currentcheckbox->checkbox->show();
  331.         currentcheckbox=currentcheckbox->next;
  332.         }
  333.  
  334.     currentradio=radioroot;
  335.     while(currentradio!=(radiorec *)NULL) {
  336.         if(currentradio->radio!=(Gradio *)NULL)
  337.             currentradio->radio->show();
  338.         currentradio=currentradio->next;
  339.         }
  340.  
  341.     currenticon=iconroot;
  342.     while(currenticon!=(iconrec *)NULL) {
  343.         if(currenticon->icon!=(Icon *)NULL)
  344.             currenticon->icon->show();
  345.         currenticon=currenticon->next;
  346.         }
  347.  
  348.     currentstring=stringroot;
  349.     while(currentstring!=(stringrec *)NULL) {
  350.         if(currentstring->string!=(Gstring *)NULL)
  351.             currentstring->string->show();
  352.         currentstring=currentstring->next;
  353.         }
  354.  
  355.     currentbutton=buttonroot;
  356.     while(currentbutton!=NULL) {
  357.         if(currentbutton->button!=NULL)
  358.             currentbutton->button->show();
  359.         currentbutton=currentbutton->next;
  360.         }
  361.  
  362.     currenttext=textroot;
  363.     while(currenttext!=NULL) {
  364.         if(currenttext->text!=NULL)
  365.             currenttext->text->show();
  366.         currenttext=currenttext->next;
  367.         }
  368.  
  369.     for(i=0;i<numlines;i++)
  370.         line_info[i].show();
  371.  
  372.     if(toolbox_indicator)
  373.         toolbox.show();
  374.     mem_turned_on=1;
  375.     showmem();
  376. }
  377.  
  378. //*********************************************************************
  379. //        CHECK_TOOLBOX
  380. //*********************************************************************
  381.  
  382. int check_toolbox()
  383. {
  384.     int mx,my,deltax,deltay;
  385.     int i;
  386.  
  387.     if(!toolbox_indicator)
  388.         return 0;
  389.         if(toolbox.moverhit()) {//2
  390.             if(the_mouse.LBP()) {//3
  391.                 mx=the_mouse.mx();
  392.                 my=the_mouse.my();
  393.                 toolbox.hide();
  394.                 toolbox.outline(15);
  395.                 while(the_mouse.LBP()) {//4
  396.                     if(mx!=the_mouse.mx() || my!=the_mouse.my()) {//5
  397.                         deltax=mx-toolbox.Getx();
  398.                         deltay=my-toolbox.Gety();
  399.                         mx=the_mouse.mx();
  400.                         my=the_mouse.my();
  401.                         toolbox.move(mx-deltax,my-deltay);
  402.                         mx=the_mouse.mx();
  403.                         my=the_mouse.my();
  404.                         }//5
  405.                     }//4
  406.                 toolbox.outline(15);
  407.                 toolbox.show();
  408.                 }//3
  409.             return 1;
  410.             }//2
  411.  
  412.         //CHECK TOOLBOX BUTTONS
  413.         if(the_mouse.LBP()) {//3
  414.             for(i=0;i<toolbox.buttoncount();i++) {//3
  415.                 mx=the_mouse.mx();
  416.                 my=the_mouse.my();
  417.                 if(toolbox.buttonhit(i)) {//4
  418.                     toolbox.buttonpress(i);
  419.                     while(the_mouse.LBP() && toolbox.buttonhit(i));
  420.                     toolbox.buttonshow(i);
  421.                     if(toolbox.buttonhit(i)) {//5
  422.                         switch(i) {//6
  423.                             case TODISK:save_all_info();
  424.                                         while(the_mouse.LBP());
  425.                                         return 1;
  426.                             case FROMDISK:read_new_info();
  427.                                         while(the_mouse.LBP());
  428.                                         return 1;
  429.                             case BEVEL:    place_bevel();
  430.                                         the_mouse.changeto(ARROW);
  431.                                         while(the_mouse.LBP());
  432.                                         return 1;
  433.                             case PANEL: place_panel();
  434.                                         the_mouse.changeto(ARROW);
  435.                                         while(the_mouse.LBP());
  436.                                         return 1;
  437.                             case CHECK: place_checkbox();
  438.                                         the_mouse.changeto(ARROW);
  439.                                         while(the_mouse.LBP());
  440.                                         return 1;
  441.                             case RADIO: place_radio();
  442.                                         the_mouse.changeto(ARROW);
  443.                                         while(the_mouse.LBP());
  444.                                         return 1;
  445.                             case GSTRING:place_string();
  446.                                         the_mouse.changeto(ARROW);
  447.                                         while(the_mouse.LBP());
  448.                                         return 1;
  449.                             case GTEXT:    place_text();
  450.                                         the_mouse.changeto(ARROW);
  451.                                         while(the_mouse.LBP());
  452.                                         return 1;
  453.                             case ICON:    place_icon();
  454.                                         the_mouse.changeto(ARROW);
  455.                                         while(the_mouse.LBP());
  456.                                         return 1;
  457.                             case BUTTON:place_button();
  458.                                         the_mouse.changeto(ARROW);
  459.                                         while(the_mouse.LBP());
  460.                                         return 1;
  461.                             case LINES:    if(numlines<100)
  462.                                             place_line();
  463.                                         the_mouse.changeto(ARROW);
  464.                                         while(the_mouse.LBP());
  465.                                         return 1;
  466.                             case SCREEN:set_screen_color();
  467.                                         return 1;
  468.                             case POOF:    clear_all_info(TRUE);
  469.                                         while(the_mouse.LBP());
  470.                                         return 1;
  471.                             case EXIT:    done=1;
  472.                                         return 1;
  473.                             }//6
  474.                     }//5
  475.                 }//4
  476.             }//3
  477. //        continue;
  478.         }//2        END TOOLBOX CHECK
  479.     return 0;
  480. }
  481.  
  482. //*********************************************************************
  483. //        CHECK_PANELS
  484. //*********************************************************************
  485.  
  486. int check_panels()
  487. {
  488.     int mx,my,deltax,deltay;
  489.     int i;
  490.  
  491.     if(check_checkboxes())
  492.         return 1;
  493.  
  494.     if(panelroot==(panelrec *)NULL)
  495.         return 0;
  496.     currentpanel=panelroot;
  497.     //Find last panel
  498.     while(currentpanel->next!=(panelrec *)NULL)
  499.         currentpanel=currentpanel->next;
  500.     //Work backwards through panels to see if any have been hit
  501.     while(currentpanel!=(panelrec *)NULL) {
  502.         if(currentpanel->panel->hit() || currentpanel->panel->sizerhit()) {
  503.             if(the_mouse.LBP()) {
  504.             if(shiftkey()) {
  505.                 modify_panel(currentpanel);
  506.                 return 1;
  507.                 }
  508.                 mx=the_mouse.mx();
  509.                 my=the_mouse.my();
  510.                 currentpanel->panel->hide();
  511.                 currentpanel->panel->outline(15);
  512.                 if(currentpanel->panel->sizerhit()) {
  513.                     while(the_mouse.LBP()) {//6
  514.                         if(mx!=the_mouse.mx() || my!=the_mouse.my()) {//7
  515.                             if(altkey())
  516.                                 the_mouse.position(mx,the_mouse.my());
  517.                             if(ctrlkey())
  518.                                 the_mouse.position(the_mouse.mx(),my);
  519.                             mx=the_mouse.mx();
  520.                             my=the_mouse.my();
  521.                             currentpanel->panel->resize((mx-currentpanel->panel->Getx()),
  522.                                                        (my-currentpanel->panel->Gety()),
  523.                                                         SAVEBGD);
  524.                             mx=the_mouse.mx();
  525.                             my=the_mouse.my();
  526.                             }//7
  527.                         }//6
  528.                     }//5
  529.                 else {
  530.                     while(the_mouse.LBP()) {//6
  531.                         if(mx!=the_mouse.mx() || my!=the_mouse.my()) {//7
  532.                             if(altkey())
  533.                                 the_mouse.position(mx,the_mouse.my());
  534.                             if(ctrlkey())
  535.                                 the_mouse.position(the_mouse.mx(),my);
  536.                             deltax=mx-currentpanel->panel->Getx();
  537.                             deltay=my-currentpanel->panel->Gety();
  538.                             mx=the_mouse.mx();
  539.                             my=the_mouse.my();
  540.                             currentpanel->panel->move(mx-deltax,my-deltay);
  541.                             mx=the_mouse.mx();
  542.                             my=the_mouse.my();
  543.                             }//7
  544.                         }//6
  545.                     }//5
  546.                 currentpanel->panel->outline(15);
  547.                 currentpanel->panel->show();
  548.                 return 1;
  549.                 }//4
  550.             }
  551.             currentpanel=currentpanel->previous;
  552.             }//3
  553.     return 0;
  554. }
  555.  
  556. //*********************************************************************
  557. //        PANEL_HIT
  558. //*********************************************************************
  559.  
  560. int panel_hit()
  561. {
  562.     int i;
  563.  
  564.     if(panelroot==(panelrec *)NULL)
  565.         return 0;
  566.     currentpanel=panelroot;
  567.     while(currentpanel!=NULL) {
  568.         if(currentpanel->panel->hit())
  569.             return 1;
  570.         currentpanel=currentpanel->next;
  571.         }
  572.     return 0;
  573. }
  574.  
  575. //*********************************************************************
  576. //        PANEL_SIZERHIT
  577. //*********************************************************************
  578.  
  579. int panel_sizerhit()
  580. {
  581.     int i;
  582.  
  583.     if(panelroot==(panelrec *)NULL)
  584.         return 0;
  585.     currentpanel=panelroot;
  586.     while(currentpanel!=(panelrec *)NULL) {
  587.         if(currentpanel->panel->sizerhit())
  588.             return 1;
  589.         currentpanel=currentpanel->next;
  590.         }
  591.     return 0;
  592. }
  593.  
  594. //*********************************************************************
  595. //        CHECK_BEVELS
  596. //*********************************************************************
  597.  
  598. int check_bevels()
  599. {
  600.     int mx,my,deltax,deltay;
  601.     int i;
  602.  
  603.     if(check_panels())
  604.         return 1;
  605.  
  606.     if(bevelroot==(bevelrec *)NULL)
  607.         return 0;
  608.     currentbevel=bevelroot;
  609.     //Find last bevel
  610.     while(currentbevel->next!=(bevelrec *)NULL)
  611.         currentbevel=currentbevel->next;
  612.     //Work backwards through bevels to see if any have been hit
  613.     while(currentbevel!=(bevelrec *)NULL) {
  614.         if(currentbevel->bevel->hit() || currentbevel->bevel->sizerhit()) {
  615.             if(the_mouse.LBP()) {
  616.             if(shiftkey()) {
  617.                 modify_bevel(currentbevel);
  618.                 return 1;
  619.                 }
  620.                 mx=the_mouse.mx();
  621.                 my=the_mouse.my();
  622.                 currentbevel->bevel->hide();
  623.                 currentbevel->bevel->outline(15);
  624.                 if(currentbevel->bevel->sizerhit()) {
  625.                     while(the_mouse.LBP()) {//6
  626.                         if(mx!=the_mouse.mx() || my!=the_mouse.my()) {//7
  627.                             if(altkey())
  628.                                 the_mouse.position(mx,the_mouse.my());
  629.                             if(ctrlkey())
  630.                                 the_mouse.position(the_mouse.mx(),my);
  631.                             mx=the_mouse.mx();
  632.                             my=the_mouse.my();
  633.                             currentbevel->bevel->resize((mx-currentbevel->bevel->Getx()),
  634.                                                        (my-currentbevel->bevel->Gety()),
  635.                                                         SAVEBGD);
  636.                             mx=the_mouse.mx();
  637.                             my=the_mouse.my();
  638.                             }//7
  639.                         }//6
  640.                     }//5
  641.                 else {
  642.                     while(the_mouse.LBP()) {//6
  643.                         if(mx!=the_mouse.mx() || my!=the_mouse.my()) {//7
  644.                             if(altkey())
  645.                                 the_mouse.position(mx,the_mouse.my());
  646.                             if(ctrlkey())
  647.                                 the_mouse.position(the_mouse.mx(),my);
  648.                             deltax=mx-currentbevel->bevel->Getx();
  649.                             deltay=my-currentbevel->bevel->Gety();
  650.                             mx=the_mouse.mx();
  651.                             my=the_mouse.my();
  652.                             currentbevel->bevel->move(mx-deltax,my-deltay);
  653.                             mx=the_mouse.mx();
  654.                             my=the_mouse.my();
  655.                             }//7
  656.                         }//6
  657.                     }//5
  658.                 currentbevel->bevel->outline(15);
  659.                 currentbevel->bevel->show();
  660.                 return 1;
  661.                 }//4
  662.             }
  663.             currentbevel=currentbevel->previous;
  664.             }//3
  665.     return 0;
  666. }
  667.  
  668. //*********************************************************************
  669. //        BEVEL_HIT
  670. //*********************************************************************
  671.  
  672. int bevel_hit()
  673. {
  674.     int i;
  675.  
  676.     if(bevelroot==(bevelrec *)NULL)
  677.         return 0;
  678.     currentbevel=bevelroot;
  679.     while(currentbevel!=NULL) {
  680.         if(currentbevel->bevel->hit())
  681.             return 1;
  682.         currentbevel=currentbevel->next;
  683.         }
  684.     return 0;
  685. }
  686.  
  687. //*********************************************************************
  688. //        BEVEL_SIZERHIT
  689. //*********************************************************************
  690.  
  691. int bevel_sizerhit()
  692. {
  693.     int i;
  694.  
  695.     if(bevelroot==(bevelrec *)NULL)
  696.         return 0;
  697.     currentbevel=bevelroot;
  698.     while(currentbevel!=(bevelrec *)NULL) {
  699.         if(currentbevel->bevel->sizerhit())
  700.             return 1;
  701.         currentbevel=currentbevel->next;
  702.         }
  703.     return 0;
  704. }
  705.  
  706. //*********************************************************************
  707. //           CHECK_CHECKBOXES
  708. //*********************************************************************
  709.  
  710. int check_checkboxes()
  711. {
  712.     int mx,my,deltax,deltay;
  713.     int i;
  714.  
  715.     if(check_radios())
  716.         return 1;
  717.  
  718.     if(checkboxroot==(checkboxrec *)NULL)
  719.         return 0;
  720.     currentcheckbox=checkboxroot;
  721.     //find the last in list
  722.     while(currentcheckbox->next!=NULL)
  723.         currentcheckbox=currentcheckbox->next;
  724.     //search backwards through list;
  725.     while(currentcheckbox!=NULL) {
  726.         if(the_mouse.LBP()) {//3
  727.             if(currentcheckbox->checkbox->hit()) {//4
  728.                 if(shiftkey()) {
  729.                     modify_checkbox(currentcheckbox);
  730.                     return 1;
  731.                     }
  732.                 mx=the_mouse.mx();
  733.                 my=the_mouse.my();
  734.                 currentcheckbox->checkbox->hide();
  735.                 currentcheckbox->checkbox->outline(15);
  736.                 while(the_mouse.LBP()) {//5
  737.                     if(mx!=the_mouse.mx() || my!=the_mouse.my()) {//6
  738.                         if(altkey())
  739.                             the_mouse.position(mx,the_mouse.my());
  740.                         if(ctrlkey())
  741.                             the_mouse.position(the_mouse.mx(),my);
  742.                         deltax=mx-currentcheckbox->checkbox->Getx();
  743.                         deltay=my-currentcheckbox->checkbox->Gety();
  744.                         mx=the_mouse.mx();
  745.                         my=the_mouse.my();
  746.                         currentcheckbox->checkbox->move(mx-deltax,my-deltay);
  747.                         mx=the_mouse.mx();
  748.                         my=the_mouse.my();
  749.                         }//6
  750.                     }//5
  751.                 currentcheckbox->checkbox->outline(15);
  752.                 currentcheckbox->checkbox->show();
  753.                 return 1;
  754.                 }//4
  755.             }//3
  756.         currentcheckbox=currentcheckbox->previous;
  757.         }//2
  758.     return 0;
  759. }
  760.  
  761. //*********************************************************************
  762. //        CHECKBOX_HIT
  763. //*********************************************************************
  764.  
  765. int checkbox_hit()
  766. {
  767.     if(checkboxroot==NULL)
  768.         return 0;
  769.     currentcheckbox=checkboxroot;
  770.     while(currentcheckbox!=NULL) {
  771.         if(currentcheckbox->checkbox->hit())
  772.             return 1;
  773.         currentcheckbox=currentcheckbox->next;
  774.         }
  775.     return 0;
  776. }
  777.  
  778. //*********************************************************************
  779. //           CHECK_RADIOS
  780. //*********************************************************************
  781.  
  782. int check_radios()
  783. {
  784.     int mx,my,deltax,deltay;
  785.     int i;
  786.  
  787.     if(check_icons())
  788.         return 1;
  789.     if(radioroot==NULL)
  790.         return 0;
  791.     currentradio=radioroot;
  792.     while(currentradio!=NULL) {
  793.         if(the_mouse.LBP()) {//3
  794.             if(currentradio->radio->hit()) {//4
  795.                 if(shiftkey()) {
  796.                     modify_radio(currentradio);
  797.                     return 1;
  798.                     }
  799.                 mx=the_mouse.mx();
  800.                 my=the_mouse.my();
  801.                 currentradio->radio->hide();
  802.                 currentradio->radio->outline(15);
  803.                 while(the_mouse.LBP()) {//5
  804.                     if(mx!=the_mouse.mx() || my!=the_mouse.my()) {//6
  805.                         if(altkey())
  806.                             the_mouse.position(mx,the_mouse.my());
  807.                         if(ctrlkey())
  808.                             the_mouse.position(the_mouse.mx(),my);
  809.                         deltax=mx-currentradio->radio->Getx();
  810.                         deltay=my-currentradio->radio->Gety();
  811.                         mx=the_mouse.mx();
  812.                         my=the_mouse.my();
  813.                         currentradio->radio->move(mx-deltax,my-deltay);
  814.                         mx=the_mouse.mx();
  815.                         my=the_mouse.my();
  816.                         }//6
  817.                     }//5
  818.                 currentradio->radio->outline(15);
  819.                 currentradio->radio->show();
  820.                 return 1;
  821.                 }//4
  822.             }//3
  823.         currentradio=currentradio->next;
  824.         }//2
  825.     return 0;
  826. }
  827.  
  828. //*********************************************************************
  829. //        RADIO_HIT
  830. //*********************************************************************
  831.  
  832. int radio_hit()
  833. {
  834.     if(radioroot==NULL)
  835.         return 0;
  836.     currentradio=radioroot;
  837.     while(currentradio!=NULL) {
  838.         if(currentradio->radio->hit())
  839.             return 1;
  840.         currentradio=currentradio->next;
  841.         }
  842.     return 0;
  843. }
  844.  
  845. //*********************************************************************
  846. //           CHECK_ICONS
  847. //*********************************************************************
  848.  
  849. int check_icons()
  850. {
  851.     int mx,my,deltax,deltay;
  852.     int i;
  853.  
  854.     if(check_strings())
  855.         return 1;
  856.     if(iconroot==NULL)
  857.         return 0;
  858.     currenticon=iconroot;
  859.     while(currenticon!=NULL) {
  860.         if(the_mouse.LBP()) {//3
  861.             if(currenticon->icon->hit()) {//4
  862.                 if(shiftkey()) {
  863.                     modify_icon(currenticon);
  864.                     return 1;
  865.                     }
  866.                 mx=the_mouse.mx();
  867.                 my=the_mouse.my();
  868.                 currenticon->icon->hide();
  869.                 currenticon->icon->outline(15);
  870.                 while(the_mouse.LBP()) {//5
  871.                     if(mx!=the_mouse.mx() || my!=the_mouse.my()) {//6
  872.                         if(altkey())
  873.                             the_mouse.position(mx,the_mouse.my());
  874.                         if(ctrlkey())
  875.                             the_mouse.position(the_mouse.mx(),my);
  876.                         deltax=mx-currenticon->icon->Getx();
  877.                         deltay=my-currenticon->icon->Gety();
  878.                         mx=the_mouse.mx();
  879.                         my=the_mouse.my();
  880.                         currenticon->icon->move(mx-deltax,my-deltay);
  881.                         mx=the_mouse.mx();
  882.                         my=the_mouse.my();
  883.                         }//6
  884.                     }//5
  885.                 currenticon->icon->outline(15);
  886.                 currenticon->icon->show();
  887.                 return 1;
  888.                 }//4
  889.             }//3
  890.         currenticon=currenticon->next;
  891.         }//2
  892.     return 0;
  893. }
  894.  
  895. //*********************************************************************
  896. //        ICON_HIT
  897. //*********************************************************************
  898.  
  899. int icon_hit()
  900. {
  901.     if(iconroot==NULL)
  902.         return 0;
  903.     currenticon=iconroot;
  904.     while(currenticon!=NULL) {
  905.         if(currenticon->icon->hit())
  906.             return 1;
  907.         currenticon=currenticon->next;
  908.         }
  909.     return 0;
  910. }
  911.  
  912. //*********************************************************************
  913. //           CHECK_STRINGS
  914. //*********************************************************************
  915.  
  916. int check_strings()
  917. {
  918.     int mx,my,deltax,deltay;
  919.     int i;
  920.  
  921.     if(check_buttons())
  922.         return 1;
  923.     if(stringroot==NULL)
  924.         return 0;
  925.     currentstring=stringroot;
  926.     while(currentstring!=NULL) {
  927.         if(the_mouse.LBP()) {//3
  928.             if(currentstring->string->hit()) {//4
  929.                 if(shiftkey()) {
  930.                     modify_string(currentstring);
  931.                     return 1;
  932.                     }
  933.                 mx=the_mouse.mx();
  934.                 my=the_mouse.my();
  935.                 currentstring->string->hide();
  936.                 currentstring->string->outline(15);
  937.                 while(the_mouse.LBP()) {//5
  938.                     if(mx!=the_mouse.mx() || my!=the_mouse.my()) {//6
  939.                         if(altkey())
  940.                             the_mouse.position(mx,the_mouse.my());
  941.                         if(ctrlkey())
  942.                             the_mouse.position(the_mouse.mx(),my);
  943.                         deltax=mx-currentstring->string->Getx();
  944.                         deltay=my-currentstring->string->Gety();
  945.                         mx=the_mouse.mx();
  946.                         my=the_mouse.my();
  947.                         currentstring->string->move(mx-deltax,my-deltay);
  948.                         mx=the_mouse.mx();
  949.                         my=the_mouse.my();
  950.                         }//6
  951.                     }//5
  952.                 currentstring->string->outline(15);
  953.                 currentstring->string->show();
  954.                 return 1;
  955.                 }//4
  956.             }//3
  957.         currentstring=currentstring->next;
  958.         }//2
  959.     return 0;
  960. }
  961.  
  962. //*********************************************************************
  963. //        STRING_HIT
  964. //*********************************************************************
  965.  
  966. int string_hit()
  967. {
  968.     if(stringroot==NULL)
  969.         return 0;
  970.     currentstring=stringroot;
  971.     while(currentstring!=NULL) {
  972.         if(currentstring->string->hit())
  973.             return 1;
  974.         currentstring=currentstring->next;
  975.         }
  976.     return 0;
  977. }
  978.  
  979. //*********************************************************************
  980. //           CHECK_BUTTONS
  981. //*********************************************************************
  982.  
  983. int check_buttons()
  984. {
  985.     int mx,my,deltax,deltay;
  986.     int i;
  987.  
  988.     if(check_lines())
  989.         return 1;
  990.     if(buttonroot==NULL)
  991.         return 0;
  992.     currentbutton=buttonroot;
  993.     while(currentbutton!=NULL) {
  994.         if(the_mouse.LBP()) {//3
  995.             if(currentbutton->button->hit()) {//4
  996.                 if(shiftkey()) {
  997.                     modify_button(currentbutton);
  998.                     return 1;
  999.                     }
  1000.                 mx=the_mouse.mx();
  1001.                 my=the_mouse.my();
  1002.                 currentbutton->button->hide();
  1003.                 currentbutton->button->outline(15);
  1004.                 while(the_mouse.LBP()) {//5
  1005.                     if(mx!=the_mouse.mx() || my!=the_mouse.my()) {//6
  1006.                         if(altkey())
  1007.                             the_mouse.position(mx,the_mouse.my());
  1008.                         if(ctrlkey())
  1009.                             the_mouse.position(the_mouse.mx(),my);
  1010.                         deltax=mx-currentbutton->button->Getx();
  1011.                         deltay=my-currentbutton->button->Gety();
  1012.                         mx=the_mouse.mx();
  1013.                         my=the_mouse.my();
  1014.                         currentbutton->button->move(mx-deltax,my-deltay);
  1015.                         mx=the_mouse.mx();
  1016.                         my=the_mouse.my();
  1017.                         }//6
  1018.                     }//5
  1019.                 currentbutton->button->outline(15);
  1020.                 currentbutton->button->show();
  1021.                 return 1;
  1022.                 }//4
  1023.             }//3
  1024.         currentbutton=currentbutton->next;
  1025.         }//2
  1026.     return 0;
  1027. }
  1028.  
  1029. //*********************************************************************
  1030. //        BUTTON_HIT
  1031. //*********************************************************************
  1032.  
  1033. int button_hit()
  1034. {
  1035.     if(buttonroot==NULL)
  1036.         return 0;
  1037.     currentbutton=buttonroot;
  1038.     while(currentbutton!=NULL) {
  1039.         if(currentbutton->button->hit())
  1040.             return 1;
  1041.         currentbutton=currentbutton->next;
  1042.         }
  1043.     return 0;
  1044. }
  1045.  
  1046. //*********************************************************************
  1047. //        CHECK_LINES
  1048. //*********************************************************************
  1049.  
  1050. int check_lines()
  1051. {
  1052.     int i;
  1053.     int mx,my,lastx,lasty;
  1054.  
  1055.     if(check_texts())
  1056.         return 1;
  1057.     for(i=0;i<numlines;i++) {
  1058.         if(the_mouse.LBP()) {
  1059.             if(line_info[i].starthit() || line_info[i].endhit()) {
  1060.                 if(line_info[i].starthit())
  1061.                     line_info[i].swap_ends();
  1062.                 the_mouse.position(line_info[i].Getx2(),line_info[i].Gety2());
  1063.                 mx=lastx=the_mouse.mx();
  1064.                 my=lastx=the_mouse.my();
  1065.                 setcolor(15);
  1066.                 setlinestyle(1,0,line_info[i].Getstyle());
  1067.                 setwritemode(XOR_PUT);
  1068.                 the_mouse.hide();
  1069.                 line(line_info[i].Getx(),line_info[i].Gety(),line_info[i].Getx2(),
  1070.                      line_info[i].Gety2());
  1071.                 the_mouse.show();
  1072.                 while(the_mouse.LBP()) {
  1073.                     if(the_mouse.mx()!=mx || the_mouse.my()!=my) {
  1074.                         if(ctrlkey())
  1075.                             the_mouse.position(the_mouse.mx(),my);
  1076.                         if(altkey())
  1077.                             the_mouse.position(mx,the_mouse.my());
  1078.                         lastx=the_mouse.mx();
  1079.                         lasty=the_mouse.my();
  1080.                         the_mouse.hide();
  1081.                         line(line_info[i].Getx(),line_info[i].Gety(),mx,my);
  1082.                         line(line_info[i].Getx(),line_info[i].Gety(),
  1083.                              lastx,lasty);
  1084.                         mx=lastx=the_mouse.mx();
  1085.                         my=lastx=the_mouse.my();
  1086.                         the_mouse.show();
  1087.                         }
  1088.                     }
  1089.                 setwritemode(COPY_PUT);
  1090.                 line_info[i].new_end(mx,my);
  1091.                 redraw_screen();
  1092.                 return 1;
  1093.                 }
  1094.             }
  1095.         }
  1096.     return 0;
  1097. }
  1098.  
  1099.  
  1100. //*********************************************************************
  1101. //        LINE_HIT
  1102. //*********************************************************************
  1103.  
  1104. int line_hit()
  1105. {
  1106.     int i;
  1107.  
  1108.     for(i=0;i<numlines;i++) {
  1109.         if((line_info[i].starthit()) || (line_info[i].endhit()))
  1110.            return 1;
  1111.         }
  1112.     return 0;
  1113. }
  1114.  
  1115. //*********************************************************************
  1116. //           CHECK_TEXTS
  1117. //*********************************************************************
  1118.  
  1119. int check_texts()
  1120. {
  1121.     int mx,my,deltax,deltay;
  1122.     int i;
  1123.  
  1124.     if(check_toolbox())
  1125.         return 1;
  1126.     if(textroot==NULL)
  1127.         return 0;
  1128.     currenttext=textroot;
  1129.     while(currenttext!=NULL) {
  1130.         if(the_mouse.LBP()) {//3
  1131.             if(currenttext->text->hit()) {//4
  1132.                 if(shiftkey()) {
  1133.                     modify_text(currenttext);
  1134.                     return 1;
  1135.                     }
  1136.                 mx=the_mouse.mx();
  1137.                 my=the_mouse.my();
  1138.                 currenttext->text->hide();
  1139.                 currenttext->text->outline(15);
  1140.                 while(the_mouse.LBP()) {//5
  1141.                     if(mx!=the_mouse.mx() || my!=the_mouse.my()) {//6
  1142.                         if(altkey())
  1143.                             the_mouse.position(mx,the_mouse.my());
  1144.                         if(ctrlkey())
  1145.                             the_mouse.position(the_mouse.mx(),my);
  1146.                         deltax=mx-currenttext->text->Getx();
  1147.                         deltay=my-currenttext->text->Gety();
  1148.                         mx=the_mouse.mx();
  1149.                         my=the_mouse.my();
  1150.                         currenttext->text->move(mx-deltax,my-deltay);
  1151.                         mx=the_mouse.mx();
  1152.                         my=the_mouse.my();
  1153.                         }//6
  1154.                     }//5
  1155.                 currenttext->text->outline(15);
  1156.                 currenttext->text->show();
  1157.                 return 1;
  1158.                 }//4
  1159.             }//3
  1160.         currenttext=currenttext->next;
  1161.         }//2
  1162.     return 0;
  1163. }
  1164.  
  1165. //*********************************************************************
  1166. //        TEXT_HIT
  1167. //*********************************************************************
  1168.  
  1169. int text_hit()
  1170. {
  1171.     if(textroot==NULL)
  1172.         return 0;
  1173.     currenttext=textroot;
  1174.     while(currenttext!=NULL) {
  1175.         if(currenttext->text->hit())
  1176.             return 1;
  1177.         currenttext=currenttext->next;
  1178.         }
  1179.     return 0;
  1180. }
  1181.